using Microsoft.Xna.Framework;

namespace WPCoco.Tasks
{
    public class MoveTo : TargetedTask<IAffine>
    {
        public MoveTo(Vector2 position, float duration)
            : base(duration)
        {
            this.position = position;
        }

        Vector2 position;
        Vector2 delta;
        Vector2 start;

        public override void InitializeWithTarget(IAffine target)
        {
            start = target.Position;
            delta = (position - start) / Duration;
        }

        public override void UpdateWithTarget(IAffine target, float time)
        {
            target.Position = start + delta * time;
        }

        public override Task Clone()
        {
            return new MoveTo(position, Duration);
        }
    }
}
